import {Text, StyleSheet, View, ScrollView} from 'react-native';
import React, {Component} from 'react';

export default class Flexbox extends Component {
  render() {
    return (
      <ScrollView>
        <Text>主轴方向</Text>
        <View>
          <Text>flexDirection:'column'</Text>
          <View style={[styles.container, styles.justifyContent]}>
            <Text style={[styles.itemBase, {flex: 1}]}>刘备</Text>
            <Text style={[styles.itemBase, {flex: 2}]}>关羽</Text>
            <Text style={[styles.itemBase, {flex: 3}]}>张飞</Text>
          </View>
        </View>
        <View>
          <Text>flexDirection:'flexColumnReverse'</Text>
          <View style={[styles.container, styles.flexColumnReverse]}>
            <Text style={[styles.itemBase]}>刘备</Text>
            <Text style={[styles.itemBase]}>关羽</Text>
            <Text style={[styles.itemBase]}>张飞</Text>
          </View>
        </View>
        <View>
          <Text>flexDirection:'row'</Text>
          <View style={[styles.container, styles.flexRow]}>
            <Text style={[styles.itemBase]}>刘备</Text>
            <Text style={[styles.itemBase]}>关羽</Text>
            <Text style={[styles.itemBase]}>张飞</Text>
          </View>
        </View>
        <View>
          <Text>flexDirection:'rowRverse'</Text>
          <View style={[styles.container, styles.flexRowReverse]}>
            <Text style={[styles.itemBase]}>刘备</Text>
            <Text style={[styles.itemBase]}>关羽</Text>
            <Text style={[styles.itemBase]}>张飞</Text>
          </View>
        </View>
      </ScrollView>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    height: 150,
    margin: 10,
    borderWidth: 1,
    borderColor: '#ddd',
  },
  itemBase: {
    height: 30,
    borderWidth: 1,
    borderColor: 'red',
    backgroundColor: '#dfb',
    // padding: 10,
    textAlign: 'center',
    // fontSize: 8,
  },
  flexColumnReverse: {
    flexDirection: 'column-reverse',
  },
  flexRow: {
    flexDirection: 'row',
  },
  flexRowReverse: {
    flexDirection: 'row-reverse',
  },
  justifyContent: {
    justifyContent: 'center',
  },
});
